package com.itheima.controller;

import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Intervention;
import com.itheima.pojo.Setmeal;
import com.itheima.service.InterventionService;
import com.itheima.service.OrderService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ZhaoShengChao
 * @create 2021/8/8 21:27
 */
@RestController
@RequestMapping("/intervention")
public class InterventionController {

    @Reference
    InterventionService interventionService;

    @Reference
    OrderService orderService;

    @RequestMapping("/getIntervention")
    public Result getIntervention(){
        try {
            Intervention intervention = interventionService.findAll();
            return new Result(true, MessageConstant.GET_INTERVENTION_SUCCESS, intervention);
        }catch (Exception e){
            return new Result(false,MessageConstant.GET_INTERVENTION_FAIL);
        }

    }

    /**
     * 通过会员id查询预约信息
     * @param memberId 会员id
     * @return
     */
    @RequestMapping("/findById")
    public Result findById(String memberId){
        try {
            Map map = orderService.getOrderInfo(memberId);
            return new Result(true, MessageConstant.GET_ORDERINFO_SUCCESS, map);
        }catch (Exception e){
            return new Result(false,MessageConstant.GET_ORDERINFO_FAIL);
        }
    }
}
